Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Glasgow Class 6 Melese Berehannu JavaScript-Core-2-Coursework-Week1#218

Open
Melesegithub wants to merge 1 commit into
CodeYourFuture:mainfrom
Melesegithub:main
Open

Glasgow Class 6 Melese Berehannu JavaScript-Core-2-Coursework-Week1#218
Melesegithub wants to merge 1 commit into
CodeYourFuture:mainfrom
Melesegithub:main

Conversation

@Melesegithub
Copy link
Copy Markdown

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Copy link
Copy Markdown

@annacollins85 annacollins85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work again 🙌 Just a few comments but you've done a really good job. Well done!

*/

// write code here
const topPlayers = (basketballTeam.topPlayers).sort()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works here since all the strings use upper case for the first letter. Be careful with using sort for strings without passing a custom function. This is because all uppercase letters are "smaller" than lower case ones. So "M" for example would be sorted before "a". Here is an article explaining in more detail and how to handle it if you want to make your sort case insensitive https://www.danywalls.com/understand-how-the-sort-method-operates-on-javascript-arrays

},
};

//we should log myPet.getName only () not required
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the case. getName is indeed a function, so we need to use () to call it. The problem here is that the get name function is not returning anything, so it returns undefined. It should be:

getName: function() {
  return "My pet's name is Fluffy";
}

Comment on lines +12 to +14
getName: function getName(name){
return name
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👏

}

student.getName("Daniel");
let studentName = student.getName("Daniel");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't affect the code working, but we should only use let to define a variable if we are going to change it later on. In other cases, we should use const. This makes our code "safer" as we will only be able to reassign variables that we define as let, and expect to be changed. (Note: there are other subtle differences with let/const related to scope, but I wouldn't advise worrying about it at this stage).

Comment thread 2-mandatory/1-recipes.js
Ingredients: ['Macharpnni', 'Cheese', 'Salt']
}}
for (item of favouriteRecipe){
console.log(item.)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exercise has made me hungry 😂

@@ -18,7 +18,17 @@ const COUNTRY_CURRENCY_CODES = [
];

function createLookup(countryCurrencyCodes) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👏

newObject[country] = countryCode;


}return newObject;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful with formatting here. The indentation on line 23 and this return statement should be on a new line.

Comment on lines +25 to +26
let countryCode = countryCurrencyCode[1];
let country = countryCurrencyCode[0];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, here we can use const. It may seem that we are reassigning these variables as we loop through the array, but we aren't, we are creating new ones on each iteration. This means they are never reassigned and disappear after each loop iteration.

@@ -20,6 +20,24 @@ let pantry = {

function createShoppingList(recipe) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Another way of doing this would be to use filter:

const missingIngredients = recipe.ingredients.filter(function (item) {
  !pantryContents.includes(ingredients)
}

@@ -21,8 +21,28 @@ const MENU = {

let cashRegister = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants